/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv3.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv3.Cache;
import org.taobao.ibatiside.model.mapperv3.CacheRef;
import org.taobao.ibatiside.model.mapperv3.Delete;
import org.taobao.ibatiside.model.mapperv3.Insert;
import org.taobao.ibatiside.model.mapperv3.Mapper;
import org.taobao.ibatiside.model.mapperv3.Mapperv3Package;
import org.taobao.ibatiside.model.mapperv3.ParameterMap;
import org.taobao.ibatiside.model.mapperv3.ResultMap;
import org.taobao.ibatiside.model.mapperv3.Select;
import org.taobao.ibatiside.model.mapperv3.Sql;
import org.taobao.ibatiside.model.mapperv3.Update;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapper</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getCacheRef <em>Cache Ref</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getCache <em>Cache</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getResultMap <em>Result Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getParameterMap <em>Parameter Map</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getSql <em>Sql</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getInsert <em>Insert</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getUpdate <em>Update</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getDelete <em>Delete</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getSelect <em>Select</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv3.impl.MapperImpl#getNamespace <em>Namespace</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MapperImpl extends EObjectImpl implements Mapper {
	/**
	 * The cached value of the '{@link #getGroup() <em>Group</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap group;

	/**
	 * The default value of the '{@link #getNamespace() <em>Namespace</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNamespace()
	 * @generated
	 * @ordered
	 */
	protected static final String NAMESPACE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNamespace() <em>Namespace</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNamespace()
	 * @generated
	 * @ordered
	 */
	protected String namespace = NAMESPACE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MapperImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv3Package.Literals.MAPPER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		if (group == null) {
			group = new BasicFeatureMap(this, Mapperv3Package.MAPPER__GROUP);
		}
		return group;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<CacheRef> getCacheRef() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__CACHE_REF);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Cache> getCache() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__CACHE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ResultMap> getResultMap() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__RESULT_MAP);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ParameterMap> getParameterMap() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__PARAMETER_MAP);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Sql> getSql() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__SQL);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Insert> getInsert() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__INSERT);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Update> getUpdate() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__UPDATE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Delete> getDelete() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__DELETE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Select> getSelect() {
		return getGroup().list(Mapperv3Package.Literals.MAPPER__SELECT);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNamespace() {
		return namespace;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNamespace(String newNamespace) {
		String oldNamespace = namespace;
		namespace = newNamespace;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv3Package.MAPPER__NAMESPACE, oldNamespace, namespace));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv3Package.MAPPER__GROUP:
				return ((InternalEList<?>)getGroup()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__CACHE_REF:
				return ((InternalEList<?>)getCacheRef()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__CACHE:
				return ((InternalEList<?>)getCache()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__RESULT_MAP:
				return ((InternalEList<?>)getResultMap()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__PARAMETER_MAP:
				return ((InternalEList<?>)getParameterMap()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__SQL:
				return ((InternalEList<?>)getSql()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__INSERT:
				return ((InternalEList<?>)getInsert()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__UPDATE:
				return ((InternalEList<?>)getUpdate()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__DELETE:
				return ((InternalEList<?>)getDelete()).basicRemove(otherEnd, msgs);
			case Mapperv3Package.MAPPER__SELECT:
				return ((InternalEList<?>)getSelect()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv3Package.MAPPER__GROUP:
				if (coreType) return getGroup();
				return ((FeatureMap.Internal)getGroup()).getWrapper();
			case Mapperv3Package.MAPPER__CACHE_REF:
				return getCacheRef();
			case Mapperv3Package.MAPPER__CACHE:
				return getCache();
			case Mapperv3Package.MAPPER__RESULT_MAP:
				return getResultMap();
			case Mapperv3Package.MAPPER__PARAMETER_MAP:
				return getParameterMap();
			case Mapperv3Package.MAPPER__SQL:
				return getSql();
			case Mapperv3Package.MAPPER__INSERT:
				return getInsert();
			case Mapperv3Package.MAPPER__UPDATE:
				return getUpdate();
			case Mapperv3Package.MAPPER__DELETE:
				return getDelete();
			case Mapperv3Package.MAPPER__SELECT:
				return getSelect();
			case Mapperv3Package.MAPPER__NAMESPACE:
				return getNamespace();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv3Package.MAPPER__GROUP:
				((FeatureMap.Internal)getGroup()).set(newValue);
				return;
			case Mapperv3Package.MAPPER__CACHE_REF:
				getCacheRef().clear();
				getCacheRef().addAll((Collection<? extends CacheRef>)newValue);
				return;
			case Mapperv3Package.MAPPER__CACHE:
				getCache().clear();
				getCache().addAll((Collection<? extends Cache>)newValue);
				return;
			case Mapperv3Package.MAPPER__RESULT_MAP:
				getResultMap().clear();
				getResultMap().addAll((Collection<? extends ResultMap>)newValue);
				return;
			case Mapperv3Package.MAPPER__PARAMETER_MAP:
				getParameterMap().clear();
				getParameterMap().addAll((Collection<? extends ParameterMap>)newValue);
				return;
			case Mapperv3Package.MAPPER__SQL:
				getSql().clear();
				getSql().addAll((Collection<? extends Sql>)newValue);
				return;
			case Mapperv3Package.MAPPER__INSERT:
				getInsert().clear();
				getInsert().addAll((Collection<? extends Insert>)newValue);
				return;
			case Mapperv3Package.MAPPER__UPDATE:
				getUpdate().clear();
				getUpdate().addAll((Collection<? extends Update>)newValue);
				return;
			case Mapperv3Package.MAPPER__DELETE:
				getDelete().clear();
				getDelete().addAll((Collection<? extends Delete>)newValue);
				return;
			case Mapperv3Package.MAPPER__SELECT:
				getSelect().clear();
				getSelect().addAll((Collection<? extends Select>)newValue);
				return;
			case Mapperv3Package.MAPPER__NAMESPACE:
				setNamespace((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv3Package.MAPPER__GROUP:
				getGroup().clear();
				return;
			case Mapperv3Package.MAPPER__CACHE_REF:
				getCacheRef().clear();
				return;
			case Mapperv3Package.MAPPER__CACHE:
				getCache().clear();
				return;
			case Mapperv3Package.MAPPER__RESULT_MAP:
				getResultMap().clear();
				return;
			case Mapperv3Package.MAPPER__PARAMETER_MAP:
				getParameterMap().clear();
				return;
			case Mapperv3Package.MAPPER__SQL:
				getSql().clear();
				return;
			case Mapperv3Package.MAPPER__INSERT:
				getInsert().clear();
				return;
			case Mapperv3Package.MAPPER__UPDATE:
				getUpdate().clear();
				return;
			case Mapperv3Package.MAPPER__DELETE:
				getDelete().clear();
				return;
			case Mapperv3Package.MAPPER__SELECT:
				getSelect().clear();
				return;
			case Mapperv3Package.MAPPER__NAMESPACE:
				setNamespace(NAMESPACE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv3Package.MAPPER__GROUP:
				return group != null && !group.isEmpty();
			case Mapperv3Package.MAPPER__CACHE_REF:
				return !getCacheRef().isEmpty();
			case Mapperv3Package.MAPPER__CACHE:
				return !getCache().isEmpty();
			case Mapperv3Package.MAPPER__RESULT_MAP:
				return !getResultMap().isEmpty();
			case Mapperv3Package.MAPPER__PARAMETER_MAP:
				return !getParameterMap().isEmpty();
			case Mapperv3Package.MAPPER__SQL:
				return !getSql().isEmpty();
			case Mapperv3Package.MAPPER__INSERT:
				return !getInsert().isEmpty();
			case Mapperv3Package.MAPPER__UPDATE:
				return !getUpdate().isEmpty();
			case Mapperv3Package.MAPPER__DELETE:
				return !getDelete().isEmpty();
			case Mapperv3Package.MAPPER__SELECT:
				return !getSelect().isEmpty();
			case Mapperv3Package.MAPPER__NAMESPACE:
				return NAMESPACE_EDEFAULT == null ? namespace != null : !NAMESPACE_EDEFAULT.equals(namespace);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (group: ");
		result.append(group);
		result.append(", namespace: ");
		result.append(namespace);
		result.append(')');
		return result.toString();
	}

} //MapperImpl
